package com.changpay.zywy.ui.activity.machinecontrol
import android.text.TextUtils
import com.changpay.zywy.R
import com.changpay.zywy.base.BaseActivity
import com.changpay.zywy.base.IView
import com.changpay.zywy.bean.ProductRateInfo
import com.changpay.zywy.ext.showToast
import com.changpay.zywy.ext.sss
import com.changpay.zywy.http.RetrofitHelper
import kotlinx.android.synthetic.main.activity_fen_run.*
import kotlinx.android.synthetic.main.title_layout.*
import java.util.HashMap


class FenRunActivity : BaseActivity(), IView {
    override fun attachLayoutRes(): Int {
        return R.layout.activity_fen_run
    }

    override fun showLoading() {

    }

    override fun hideLoading() {

    }

    override fun showDefaultMsg(msg: String) {
        showToast(msg)
    }

    override fun showMsg(msg: String) {
        showToast(msg)
    }

    override fun showError(errorMsg: String) {
        showToast(errorMsg)
    }




    override fun initData() {


    }

    override fun initView() {
        tv_title.text = intent.getStringExtra("title")
        iv_back.setOnClickListener{finish()}
    }

    override fun start() {
        loadData()

    }

    private fun loadData() {
        val params = HashMap<String, String>()
        params["key"] = token
        params["goods_id"] = intent.getStringExtra("goods_id")
        val others_member_id = intent.getStringExtra("others_member_id")
        if (!TextUtils.isEmpty(others_member_id)) {
            params["others_member_id"] = others_member_id
        }
        RetrofitHelper.service.myProductRateInfo(params).sss(this)
        {
            setViewData(it.result)
        }
    }


    private fun setViewData(data: ProductRateInfo) {

        tv_company_name.text = data.gc_name
        tv_goods_name.text = data.goods_name + data.goods_serial
        tv_cloud_pay.text = data.cloud_admin_share + "%"
        tv_credit_card.text = data.lineCard_admin_share + "%"
        tv_bank_card.text = data.bankCard_admin_share + "%"
        tv_fast_pay.text = data.quickPay_admin_share + "%"
        tv_code_pay.text = data.scaveCode_admin_share + "%"
        tv_bank_card_top.text = data.admin_top_share

        tv_machine_award.text = data.activate_rewards
        tv_recommend_award.text = data.goods_rewards

    }
}
